﻿using Abp.Auditing;
using Abp.Configuration.Startup;
using Abp.Dependency;
using Abp.Modules;
using Castle.Facilities.Logging;
using Basefr.Logging.Auditings;
using Basefr.Logging.NLogExtensions;
using Basefr.Modules;

namespace Basefr.Logging
{
    [DependsOn(typeof(Basefr.Module))]
    public class Module : ModuleBase<Module>
    {
        public override void PreInitialize()
        {
            //使用自定义的AuditingStore代替ABP默认的SimpleLogAuditingStore
            Configuration.ReplaceService<IAuditingStore, AuditingStore>(DependencyLifeStyle.Transient);
        }

        public override void PostInitialize()
        {
            //使用NLog作为日志组件
            IocManager.IocContainer.AddFacility<LoggingFacility>(f => f.UseNLog().WithConfig("NLog.config"));

            //使用Log4Net作为日志组件
            //IocManager.IocContainer.AddFacility<LoggingFacility>(f => f.UseAbpLog4Net().WithConfig("bin\\log4net.config"));
        }
    }
}
